package Work01;

import javax.imageio.IIOException;
import java.io.*;
import java.nio.file.Path;

public class Test {
    public static void main(String[] args) {
        String path="test";
        File file = new File(path);
        if (!file.exists()){
            file .mkdir();
        }

        String pathFile="E:\\jnh\\git\\test-java\\homework\\java1228\\student\\jinh\\mywork\\src\\Work01\\Test.java";
        String targetPath="test\\Test,java";
        FileInputStream fis=null;
        FileOutputStream fileOutputStream=null;
        try {
            File srcfile = new File(pathFile);
            //读取要复制的文件内容
            fis = new FileInputStream(pathFile);
            long len=srcfile.length();
            byte[] b = new byte[(int)len];
            fis.read(b);

            //把读出来的字节数组写入文件
            File targetFile = new File(targetPath);
            FileOutputStream fileOutpuStream=new FileOutputStream(targetFile);
            fileOutpuStream.write(b);
            fileOutpuStream.flush();
        }catch (FileNotFoundException e){
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try{
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}